Not applicable.
A. Field of the Invention
The present invention relates generally to a graphics system for a personal computer. More particularly, the present invention relates to a system for providing texture to images on a computer screen. Still more particularly, the present invention relates to an improved texturing technique that uses a selectable mode texture filter for applying a texture map to pixels on a screen.
B. Background of the Invention
Before the availability of the personal computer (commonly referred to as a PC), computer graphics packages were expensive tools primarily reserved for industrial applications. Early microcomputers were only capable of rendering simple line drawings with a low screen resolution (256 pixelsxc3x97256 pixels, for example). As microcomputers evolved, higher resolution color displays became available, and software applications routinely provided data output in a graphical format. The graphics techniques used were unstructured, with objects defined in terms of absolute coordinates using straight lines. Subsequently, graphics xe2x80x9cprimitivesxe2x80x9d were developed, enabling circles, ellipses, rectangles and polygons to be drawn with single software instructions. The use of primitives for drawing shapes increased the speed at which the images could be rendered.
The availability of computer graphics has generated a demand for higher resolutions and three dimensional (3-D) rendering capabilities. Computer animation and games, in particular, have spawned a revolution in computer graphics capabilities. A 3-D image can be represented in a computer system as a collection of graphical objects, such as polygons, lines, and points. A set of vertex points defines a polygon. Associated with each point are certain parameters, such as shading, texturing, color, and the like. Identification of other non-vertex points within the polygon typically is done through the use of linear interpolation. Once interpolated, the polygon can be rendered on a computer monitor by scanning of successive rows of the polygon. By drawing multiple polygons on the screen at a time, an object can be drawn.
Further advancements in the computer graphics arena have led to techniques for enhancing the realistic appearance of objects drawn on the screen. Texture mapping, one of the significant aspects of 3-D graphics permits images on a computer screen to be displayed with texture. Thus, for example, a table top can be textured to have the appearance of a wood-grain or marble surface, or any other desired surface. In computer graphics, a texture map is an array of pixels that represents a particular pattern, such as a single brick. By repeatedly applying the texture map of a brick to side of a building, for example, the side will appear as a brick wall. The amount of memory required to represent the brick wall is minimal because only enough memory is required to store a texture map for a single brick. A pixel in a texture map is called a xe2x80x9ctexel.xe2x80x9d A texture map typically is constructed from a two-dimensional array of texels (typically represented with digital values). A u, v address or coordinate associated with each texel value in the texture map. Pixels on the computer screen, however, are assigned x, y addresses to represent the spatial location of the pixel on the computer screen. Thus, a pixel with an address of (10, 14) would be in the tenth column of pixels, fourteen rows down on the computer screen. Because texel values are not assigned an x, y value when applying a texture map to a polygon on the screen, a conversion from an x, y pixel address to a u, v texture map address is necessary. The conversion process is termed xe2x80x9cmapping.xe2x80x9d A texel mapping algorithm thus uses an x, y pixel address to look up a corresponding texel in a texture map. The texel is then used to render the pixel at the x, y screen address.
Ordinarily, an x, y pixel address converts to a fractional u, v texture map coordinate. A xe2x80x9c10.16xe2x80x9d format is typically used to represent the converted u and v coordinates in which 10 bits are used for the integer portion of the coordinate along with 16 fractional bits. The coordinates of texel values in a texel map, however, include only integer values, and thus the converted u, v coordinate usually will not correspond exactly to a texel in the texel map. Point sampling provides the simplest method for selecting a texel from a texel map for applying to objects. In point sampling, the texel from the texel map closest to the fractional u, v coordinate is selected to render the corresponding x, y pixel on the screen. For example and referring to FIG. 1, four texels A, B, C, and D from a texture map are shown with their integer u, v coordinates. An address in x, y space might convert to u, v texture space as point P1 with u, v coordinates (1.25, 1.30). Of the four closest texels A, B, C, and D, point P1 is closest texel A. Using the point sampling technique, texel A would be selected to be mapped onto the x, y pixel associated with point P1. With point sampling, only one texel is used for each pixel during mapping and thus only one memory access is required to fetch the selected nearest texel. Although simple and fast, images rendered with point sampling may appear blocky and xe2x80x9cscintillate,xe2x80x9d or sparkle, when the object moves detracting from the appearance of the object.
In certain instances, however, point sampled images are acceptable. For example, rendered with perspective, a brick wall may appear to recede into the distance. The appearance of the foreground part of the wall would suffer if point sampling was used. However, the problems associated with point sampled images would be imperceptible if point sampling was used to texture the distant part of the wall because of the diminished resolution associated with objects drawn to appear distant.
Filtering techniques such as bilinear averaging result generally in higher quality texture images. Bilinear averaging combines the four nearest texels in a weighted average to derive a single texel value used to render the pixel. Referring again to FIG. 1, in the u axis point P1 is generally closer to texel A than texel B and closer to texel C than texel D. Thus, the bilinear weighted average of texels A, B, C, and D generally weights A more than B, and C more than D. In the v axis, the result is similar with texels A and B weighted more heavily than texels C and D because point PI is closer to texels A and B than C and D. Bilinear averaged images achieve superior quality than point sampled images, but require more computer and processing power. Because four texels are averaged together, four accesses to texture memory are required to fetch the four texels, taking considerably more time than the single memory access required by point sampling. Further, the averaging process, including calculation of the weights associated with each texel to be averaged, requires time to perform.
Graphics systems that employ texturing typically use only one texture mapping technique at a time when rendering images. Thus, one graphics system might use point sampling for faster speed, while other systems might use bilinear averaging for higher quality. Both types of systems, however, suffer from the problems attendant to each texturing technique.
There is a need for an improved graphics system that provides the high quality texture mapped images of bilinear averaging and other filtering methods, at speeds comparable to point sampling techniques. Such a system would permit high quality graphics at speeds faster than permitted by standard filtering techniques. Despite the advantages such a system would offer, to date no such system has been developed.
A software graphics engine is disclosed which includes a selectable mode filter for improved texture mapping. As part of the texturing process, and in accordance with prior techniques an x, y pixel address is converted to a u, v coordinate in a texture map. The converted u, v coordinate includes integer and fractional portions. The texture map includes texels with only integer coordinates. Depending on the location of the u, v coordinate relative to the four closest texels, the present invention selects one of three texture mapping schemes to select a texel value from the texel map to use in rendering the pixel at the x, y pixel address. The three texture mapping schemes used to select the texel value preferably include point sampling (in which the nearest texel from the texture map is selected), two-texel averaging (in which the closest two texels are combined in a weighted average), and four-texel averaging (in which the closest four texels are combined in a weighted average).
In accordance with the present invention, the software graphics engine selects the texture mapping scheme to implement based upon some predetermined criteria. Accordingly, the point sampling scheme preferably is implemented when the u, v coordinate is within a predetermined distance from a texel. If the point sampling scheme is implemented, the closest texel is selected and used to render the x, y pixel. Point sampling generally is faster than other texture mapping techniques, but provides graphics images whose quality is inferior to other techniques. By only implementing point sampling when the converted u, v coordinate is relatively close to a texel value in the texel map, graphics distortion is kept at a minimum, while the system speed is maximized.
If, however, the converted u, v coordinate is located within a predetermined distance from two texels, but greater than a certain distance from all other texels, then the two closest texels are combined in a weighted average. The two-texel average weights the closest texel proportionately more heavily than the other texel. The weights calculated for each texel in the two-texel average is a function of the proximity of each texel to the converted u, v coordinate. Two-texel averaging generally is slower than point sampling because two texels must be fetched from memory, weights for each texel must be calculated, and the texels then must be combined in a weighted average. The quality of two-texel filtered images, however, is generally superior to images produced by point sampling. In addition, the graphics processing of a two-texel filtering scheme is faster than a four-texel averaging scheme.
If the mapped u, v coordinate is sufficiently distant from all four of the four closest texels, the four closest texels are combined in a weighted average based upon the proximity of each texel to the converted u, v coordinate values. Consequently, texels closer to the u, v location are weighted more heavily than the texels located farther away from the converted coordinates. Four-texel averaging generally provides superior computer graphics, but requires the time-consuming retrieval of four texels from memory, as well as the calculation of a weight for each texel and the weighted combination of the four texels.
By providing software that implements a dynamically selectable filter that performs point sampling, as well as two or four-texel averaging, the graphics system can achieve the speeds approaching those of systems that use only point sampling, while at the same time obtaining superior quality texturing. Moreover, the areas in the texture map in which each of the three texture mapping techniques is used is adjustable permitting increased system flexibility to fine tune the texture mapping process. Thus, an application program uses the fast point sampling when quality and accuracy of an individual texel is of less concern, while using a higher quality scheme in other instances.